    <div class="easyui-tabs" id="customerView-tabs" border="false">
		<div id="customerView" title="客户详细信息"  style="width:800px;height:500px;padding:10px 20px;">
	
        	<div class="ftitle">客户信息</div>
        	<div class="headphoto imgDiv imgMiddle" id="headPic">
        	</div>
        	<div class="cdetail">
        		<div class="fitem">
            		<span class="view_customer11">姓名 : <span id="view_name"></span></span>
            		<span class="view_customer11">性别 : <span id="view_sex"></span></span>
            		<span class="view_customer11">年龄 : <span id="view_age"></span></span>
            	</div>
            	<div class="fitem">
            		<span class="view_customer11">客户类别 : <span id="view_customerType"></span></span>
            		<span class="view_customer11">整形项目 : <span id="view_items"></span></span>
            		<span class="view_customer11">省份 : <span id="view_province"></span></span>
            	</div>
            	<div class="fitem">
            		<span class="view_customer11">城市 : <span id="view_city"></span></span>
            		<span class="view_customer11">职业 : <span id="view_work"></span></span>
                	<span class="view_customer11">电话 : <span id="view_cell"></span></span>
            	</div>
            	<div class="fitem">
            	    <span class="view_customer11">QQ : <span id="view_qq"></span></span>
            		<span class="view_customer11">微信 : <span id="view_weixin"></span></span>
                	<span class="view_customer11">Email : <span id="view_email"></span></span>

            	</div>
            	<div class="fitem">
            	    <span class="view_customer11">添加人 : <span id="view_addUser"></span></span>
            		<span class="view_customer11">时间 : <span id="view_addTime"></span></span>
            		<span class="view_customer11">最近更改人 : <span id="view_editUser"></span></span>
            	</div>
            	<div class="fitem">
            		<span class="view_customer11">时间 : <span id="view_editTime"></span></span> 
            	</div>
        	</div>
            <div style="margin:5px 0;clear:both"></div>
            <div class="ftitle">对客户的评论 <a href="javascript:viewCustomerJs.openComment()"> 评论 </a></div>
            <div id="customerComment" class="easyui-accordion" style="width:790px;height:250px;"  border="false">
        	</div>
                                                         
    	</div>
    	<div title="客户咨询信息" style="padding:10px">
    		<table id="consultList"></table>
        </div>
        <div title="手术记录" style="padding:10px">
			<table id="surgeryList"></table>
        </div>
    </div>

	<div class="easyui-dialog" id="addComment" closed="true" style="width:550px;height:250px">
		 <form id="addComment" method="post" novalidate>
        	<div class="ftitle">评论</div>
        	<input name="comment_customer" type="hidden">
            <div>
                <textarea name="add_comment" style="height:60px;width:90%;margin-left:10px"></textarea>
            </div>
            <div style="text-align:center;padding:5px">
            	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="viewCustomerJs.submitComment()">Submit</a>
        	</div>
            
        </form>
	</div>
	<div id="ConsultDetail" title="咨询详情" class="easyui-dialog"  closed="true" style="width:850px;height:450px">
    </div>	
    <div id="surgeryDetail" title="手术详情" class="easyui-dialog"  closed="true" style="width:850px;height:450px">
    </div>	
	<script type="text/javascript">
(function( viewCustomerJs, $, undefined ) {	
	viewCustomerJs.init = function(){
		openCustomer();
	};
	viewCustomerJs.viewCustomerComments = function(result){
        	var row = jQuery.parseJSON(result.payload.value);
    		$(row).each(function(index){
    			var record = row[index];
    			var title = record.user+' 于 '+record.time+' 评论';
    			var link = '<div style="text-align:center;padding:5px"><a href="#" class="easyui-linkbutton" onclick="javascript:viewCustomerJs.deleteComment('
    						+record.id+',\''+title+'\')">删除</a></div>';
    			var content = '<p style="padding:10px;">'+record.content+'</p>'+link;
    			
    			$('#customerComment').accordion('add', {
    				title: title,
    				content: content,
    				selected: false
    			});
    		});
	};
	viewCustomerJs.viewCustomer = function(result){
        	var row = jQuery.parseJSON(result.payload.value);
    		
    		$('#view_name').html(row.name);
    		$('#view_age').html(row.age);
    		$('#view_sex').html(row.sex);
    		$('#view_province').html(row.province);
    		$('#view_city').html(row.city);
    		$('#view_qq').html(row.qq);
    		$('#view_weixin').html(row.weixin);
    		$('#view_email').html(row.email);
    		$('#view_work').html(row.work);
    		$('#view_addUser').html(row.addUser);
    		$('#view_addTime').html(row.addTime);
    		$('#view_editTime').html(row.lastEditTime);
    		$('#view_items').html(row.items);
    		$('#view_customerType').html(row.customerType);
    		
    		var img = '<span></span><img src="images/head.jpg" style="height:150px;width:150px;"/>';
    		if(row.image != "" && row.image != undefined)
    		{
    			img = '<span></span><img src="'+row.image+'"/>';
    		}
    		$('#headPic').html(img);
    		
	};

	function openCustomer(){
		var id = customerActionJs.getCustomerID();
		if(id != "")
		{
			workbenchJs.loadData("dispatch/customer/query?id="+id,viewCustomerJs.viewCustomer,"查询客户信息");
			workbenchJs.loadData("dispatch/customer/comments/query?customer="+id,viewCustomerJs.viewCustomerComments,"查看客户评论");
			workbenchJs.loadData("dispatch/customer/consult/list?customer="+id,viewCustomerJs.loadConsultData,"查看咨询信息");
			workbenchJs.loadData("dispatch/customer/surgeryRecord/all?customerId="+id,viewCustomerJs.loadSurgeryRecord,"查看手术记录");
        	
		}else
			{
				$.messager.alert("Error","customer id not set");
			}

	};
	viewCustomerJs.deleteComment = function(id,index){
		 $.get(
			  'dispatch/customer/comments/delete',
			   {
			      id:id
			   },
			   function(result) 
			   {
					result = jQuery.parseJSON(result);
				    var res = result.result;
				    if(res == "SUCCESS")
				    {
				        $('#customerComment').accordion('remove', index);
				        	
				    }else if(res == "NOT_AUTHORIZED")
	                {
	                	$.messager.alert("Error","您没有权限 删除评论");
	                }else if(res == "COMPONENT_ERROR")
				    {
				        $.messager.alert("Error",result.payload.value);
				    }else
				    {
				        $.messager.alert("Error",result.result);
				    }
			  });
	};
	viewCustomerJs.openComment = function(){
		var id = customerActionJs.getCustomerID();
		$('#addComment').dialog('open').dialog('setTitle','添加评论');
		$('#addComment').form('clear');
		$("input[name='comment_customer']").attr("value",id);
	};
	viewCustomerJs.submitComment = function(){
		var url = "dispatch/customer/comments/add";
		$('#addComment').dialog('close');
		
		$.post(
			url,
			{
				customer:$("input[name='comment_customer']").val(),
				comment:$("textarea[name='add_comment']").val()
			},
			function (result)
			{
				result = jQuery.parseJSON(result);
		    	var res = result.result;
		        if(res == "SUCCESS")
		        {
		        	var record = jQuery.parseJSON(result.payload.value);
		        	$('#customerComment').accordion('add', {
						title: record.user+' 于 '+record.time+' 评论',
						content: '<p style="padding:10px;">'+record.content+'</p>',
						selected: false
					});
		        	
		        }else if(res == "NOT_AUTHORIZED")
                {
                	$.messager.alert("Error","您没有权限 添加评论");
                }else if(res == "COMPONENT_ERROR")
		        {
		        	$.messager.alert("Error",result.payload.value);
		        }else
		        {
		        	$.messager.alert("Error",result.result);
		        }
			});

	};

	$('#surgeryList').datagrid({
		fitColumns:true,
		singleSelect:true,
		url:null,
		rownumbers:true,
	    columns:[[
					{title:'名称',field:'title',width:200},
	             	{title:'手术项目',field:'items',width:80,sortable:true},
	             	{title:'手术时间',field:'surgeryTime',width:80,sortable:true},
	             ]],
		pagination:false,
	    onLoadSuccess: function(){   
	        $('#surgeryList').datagrid('loaded');
	    },

	    onDblClickCell: openSurgery
	});
	
	$('#consultList').datagrid({
		fitColumns:true,
		singleSelect:true,
		url:null,
		rownumbers:true,
	    columns:[[
					{title:'ID',field:'id',width:80},
	             	{title:'标题',field:'title',width:200,sortable:true},
	             	{title:'创建者',field:'addUser',width:80,sortable:true},
	             ]],
		pagination:false,
	    onLoadSuccess: function(){   
	        $('#consultList').datagrid('loaded');
	    },

	    onDblClickCell: openConsult
	});
	function openConsult(){
        var row = $('#consultList').datagrid('getSelected');
        if (row){
    		$('#ConsultDetail').dialog("open");
    		$('#ConsultDetail').dialog('refresh','component/customer/viewConsult.jsp?id='+row.id);
        }else
        	{
        		$.messager.alert("Error","请选择一条记录");
        	}
	};
	function openSurgery(){
        var row = $('#surgeryList').datagrid('getSelected');
        if (row){
    		$('#surgeryDetail').dialog("open");
    		$('#surgeryDetail').dialog('refresh','component/customer/viewSurgeryRecord.jsp?id='+row.id);
        }else
        	{
        		$.messager.alert("Error","请选择一条记录");
        	}
	};
	viewCustomerJs.loadConsultData = function(result){
		var row = jQuery.parseJSON(result.payload.value);
	    $('#consultList').datagrid('loadData',row);
	};
	viewCustomerJs.loadSurgeryRecord = function(result){
		var row = jQuery.parseJSON(result.payload.value);
	    $('#surgeryList').datagrid('loadData',row);
	};
		
}( window.viewCustomerJs = window.viewCustomerJs || {}, jQuery ));

$(function(){
	viewCustomerJs.init();
});
	</script>
	    <style type="text/css">
        .view_customer11{
        	margin-bottom:5px;
        	margin-left:9px;
        	display:inline-block;
            width:190px;
        }
        .headphoto{
        	width:155px;
        	height:155px;
        	float:left;
        }
    </style>